/**
 * @author Rudy Kaplan Depena (The University of Texas at Austin)
 */
package com.utaustin.mirankerlab.ultrawrap.compiler.expressionTree.sparql;

/** This is a Node for an expression tree*/
public class Node {
	
	//instance variables
	private Node parent;
	private Node leftChild;
	private Node rightChild;
	private int level;
	
	/**
	 * Default Constructor
	 */
	public Node(){
		this.parent = null;
		this.leftChild = null;
		this.rightChild = null;
		level = 0;
	}
	
	/**
	 * Acquire left child node
	 * @return the leftChild
	 */
	public Node getLeftChild() { return leftChild; }



	/**
	 * Set left child node
	 * @param leftChild the leftChild to set
	 */
	public void setLeftChild(Node leftChild) { 
		this.leftChild = leftChild; 
		this.leftChild.setParent(this);
		this.leftChild.setLevel(this.level+1);
	}



	/**
	 * Acquire right child node
	 * @return the rightChild
	 */
	public Node getRightChild() { return rightChild; }



	/**
	 * Set right child node
	 * @param rightChild the rightChild to set
	 */
	public void setRightChild(Node rightChild) { 
		this.rightChild = rightChild;
		this.rightChild.setParent(this);
		this.rightChild.setLevel(this.level+1);
	}

	/**
	 * Get parent
	 * @return the parent
	 */
	public Node getParent() { return parent; }

	/**
	 * Set parent
	 * @param parent 
	 */
	public void setParent(Node parent) { this.parent = parent; }
	
	/**
	 * Gets level of node in tree
	 * @return level
	 */
	public int getLevel(){ return (parent == null) ? 0 : parent.getLevel() + 1; }
	
	public void setLevel(int level){
		this.level = level;
	}

	/**
	 * Must Implement your own flavor of two string method
	 * (whether or not you are an operand or an operator)
	 * @return String
	 */
	public String toString(){
		return "Node";
	}
	
	/**
	 * Generate SQL Node
	 * @return sql representation of node
	 */
	public String generateSql(boolean calledByLeftJoin){
		return "SqlNode";
	}

}
